using System;
using System.Collections.Generic;
using libEngineAI.Interfaces;

namespace libEngineAI
{
	/// <summary>
	/// Define a movement
	/// </summary>
	public class Movement
	{
		public IPiece PieceMoved { get; set; }
		//public IEnumerable<KeyValuePair<Coordinate,Coordinate>> Trace { get; set; }
		public Coordinate Begin { get; set; }
		public Coordinate End { get; set; }
		public bool Eat { get; set; }
		public IPiece PieceEated { get; set; }
		//public Coordinate PieceEatedCoords { get; set; }
		public bool TransformationMovement { get; set; }
		public int PastValue { get; set; }

		public override bool Equals(object obj)
		{
			bool res = false;

			if( obj.GetType() == GetType() )
			{
				Movement m = obj as Movement;

				if( m.Begin.Equals(Begin) && m.End.Equals(End) && PieceMoved.Equals( m.PieceMoved ))
				//if( m.Begin.Equals(Begin) && m.End.Equals(End) && m.Eat == Eat )
					res = true;
			}

			return res;
		}

		public override int GetHashCode()
		{
			return Begin.x ^ Begin.y ^ End.x ^ End.y;
		}

		public Movement Clone()
		{
			return new Movement 
			{
				PieceMoved = this.PieceMoved,
				PieceEated = this.PieceEated,
				Begin = this.Begin, 
				End = this.End, Eat = this.Eat, 
				//PieceEatedCoords = PieceEatedCoords, 
				TransformationMovement = this.TransformationMovement,
				PastValue = this.PastValue
			};
		}
	}
}

